<?php
include 'mysql.php';


if(isset($_SERVER['REQUEST_METHOD'])&&strtolower($_SERVER['REQUEST_METHOD'])=='post')
{

    $param = $_REQUEST['Form'] ;
    $fax = $param['fax'];
    $phone = $param['phone'];
    $mail = $param['mail'];
    $address = $param['address'];
    $logo = $param['logo'];
    if($_FILES['logo'])
    {
        $filename = $_FILES['logo']['type'];
        $newname = './logo/'.time().'.jpg';
        if(in_array(strtolower($filename),array('image/jpeg','image/png')))
        {
            if(!move_uploaded_file($_FILES['logo']['tmp_name'] ,$newname) )
            {
                die ('图片上传失败');
            }
            else
            {

                $logo  = $newname ;
            }
        }

    }

    $query = "UPDATE  base_info SET `fax` = '".$fax."',`phone` = '".$phone."', `mail` = '".$mail."', `address` = '".$address."', `logo` = '".$logo."'";

    $result=$mysqli->query($query);
    if(!$result)
    {
        echo  "<script>alert('编辑失败')</script>";
    }


}



$result = $mysqli->query("select * from base_info WHERE id = 1");
$row = $result->fetch_assoc();

?>

    <!doctype html>
    <html>
<head>
    <title>后台管理</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <link href="css/admin_full.css" rel="stylesheet" />
    <script src="js/jquery.js"></script>
    <script type="text/javascript">
		$(function(){

            $('form[name="form_submit"]').submit(function(){


                var phone = $('#phone').val();
                var logo = $('#logo').val();
                var mail = $('#mail').val();
                var address = $('#address').val();
                var fax = $('#fax').val();

                if(cover==""){
                    $('#cover').focus();
                    return false ;
                }

                if(!phone.length){
                    $('#phone').focus();
                    return false ;
                }

                if(!fax.length){
                    $('#fax').focus();
                    return false ;
                }

                if(!mail.length){
                    $('#mail').focus();
                    return false ;
                }

                if(!address.length){
                    $('#address').focus();
                    return false ;
                }

            });
        })

		</script>
</head>
<body>

<div id="popup"></div>
<div class="wrap J_check_wrap">
    <div class="h_a">功能说明</div>
    <div class="prompt_text">
       设置网站基本信息
    </div>
    <div class="h_a">网站基本信息</div>
    <div class="search_type cc mb10">
        <form action=" " method="post" name="form_submit" enctype="multipart/form-data">
              <div class="ul_wrap">
                <label>网站logo：</label>
                <img src="<?php echo @$row['logo'];?>" width="115" height="75" >
             </div>
             <div class="ul_wrap">
                <label>修改logo：</label>
                <input type="file" class="input length_3" name="logo" id="logo"  ><span>尺寸：115*95</span>
             </div>
            <div class="ul_wrap">
                <label>网站电话：</label>
                <input type="text" class="input length_3" name="Form[phone]" id="phone" value="<?php echo $row['phone'];?>" placeholder="必填">
             </div>
             <div class="ul_wrap">
                <label>网站传真：</label>
                <input type="text" class="input length_3" name="Form[fax]" id="fax" value="<?php echo $row['fax'];?>" placeholder="必填">
             </div>
             <div class="ul_wrap">
                <label>网站邮箱：</label>
                <input type="text" class="input length_3" name="Form[mail]" id="mail" value="<?php echo $row['mail'];?>" placeholder="必填">
             </div>
            <div class="ul_wrap">
                <label>网站地址：</label>
                <input type="text" class="input length_3" name="Form[address]" id="address" value="<?php echo $row['address'];?>" placeholder="必填">
             </div>
            <input type="hidden" class="input length_3" name="Form[logo]"   value="<?php echo @$row['logo'];?>" >
             <div class="ul_wrap"> <button class="btn" type="submit">确定</button> </div>
        </form>
    </div>
</div>
</body>
</html>

<?php $mysqli->close(); ?>